/*
 * 								SYMBIOS
 *
 * 	Selection.cpp
 *  Created on: Jun 1, 2009
 *  Author: andrei
 */

#include <math.h>
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include "gesture_rec.h"
#include "parameters.h"

int size[10];
int previous_indice;
CvPoint2D32f ppreviousCenter;


// INITIALISE LA RECONNAISSANCE DES MOUVEMENTS
void initRecognition()
{
	previous_indice=0;
	for (int y=0;y<9;y++)
		size[y]=0;
}


//RECONNAIT LE GESTE SELECTION
int recognizeSelection(int newsize, CvPoint2D32f center)
{
	float Dx = fabs(ppreviousCenter.x-center.x);
	float Dy = fabs(ppreviousCenter.y-center.y);
	int indice = ((previous_indice+1)%10);
	float res=(float)size[previous_indice]/ (float)newsize;
	if (( (size[previous_indice]!=0) && res > SYMB_SELECT ) && (Dx+Dy>SYMB_CENTER_JUMP) )
		{
			size[indice] = newsize;
			previous_indice = indice;
			ppreviousCenter.x = center.x;
			ppreviousCenter.y = center.y;
			return 1;
		}
/*	float res1=(float)newsize/(float)(size[previous_indice]);
	if (( (size[previous_indice]!=0) && res1 > SYMB_RELEASE ) )
	{
		size[indice] = newsize;
		previous_indice = indice;
		return 2;
	}
*/
	size[indice] = newsize;
	previous_indice = indice;
	return 0;
	ppreviousCenter.x = center.x;
	ppreviousCenter.y = center.y;
}
